﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mailer.Model.Types;
using NHibernate;

namespace Mailer.Model.Repositories
{
	public class MailRepository
	{
		public static List<Mail> GetForApplications(Guid appid)
		{
			List<Mail> ret = new List<Mail>();

			ISession sess = SessionUtilities.BeginSession();
			if (sess != null)
			{

				//	using (ISession s = SessionUtilities.GetSession())
				//	{
				Application app = sess.Get<Application>(appid);
				if (app != null)
				{
					foreach (Mail m in app.Mails)
						ret.Add(m);
				}
				SessionUtilities.EndSession(sess);
			}


			return ret;
		}

	}
}
